#!/usr/bin/env python

# -------
# Imports:
# -------
import os, re
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext.webapp import template
from settings import *
from core.models import *
import logging

# -----------------------------------------
class GetCellComplex(webapp.RequestHandler):
# -----------------------------------------
	# -----------
    def get(self):
	# -----------
        # Parse out the URL's ID
        urlIdM = re.search(r'/cell_complex/image/(?P<id>\w+)', self.request.path)
        urlId = int(urlIdM.group('id'))

        # Query for the cell complex
        cellComplex = CellComplex.get_by_id(urlId)

        # Make sure we found something
        if cellComplex is not None:
            # Return the image
            self.response.headers['Content-Type'] = 'image/svg+xml'
            self.response.out.write(cellComplex.renderToSVG())
